home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
params
/
frmsearc.frm
< prev
next >
Wrap
Text File
|
1994-10-16
|
3KB
|
120 lines
VERSION 2.00
Begin Form frmSearch
BackColor = &H00C0C0C0&
BorderStyle = 3 'Fixed Double
ClientHeight = 2415
ClientLeft = 1725
ClientTop = 5295
ClientWidth = 6765
Height = 2820
Left = 1665
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 540
ScaleWidth = 540
Top = 4950
Width = 6885
Begin CommandButton cmdCancel
BackColor = &H00C0C0C0&
Cancel = -1 'True
Caption = "&Cancel"
Height = 435
Left = 4770
TabIndex = 2
Top = 930
Width = 1425
End
Begin CommandButton cmdSelect
BackColor = &H00C0C0C0&
Caption = "&Select"
Default = -1 'True
Height = 435
Left = 4770
TabIndex = 1
Top = 210
Width = 1425
End
Begin ListBox lstAvailable
Height = 1980
Left = 180
TabIndex = 0
Top = 210
Width = 4275
End
Begin Shape shpShadow
BackColor = &H00808080&
BackStyle = 1 'Opaque
BorderColor = &H00808080&
Height = 1890
Index = 3
Left = 300
Top = 360
Width = 4245
End
End
Option Explicit
Sub cmdCancel_Click ()
Unload Me
End Sub
Sub cmdSelect_Click ()
ReturnValue
End Sub
Sub Form_Load ()
SetDialogMenu Me
PlaceDialog frmMain, Me, DLG_STANDARD
Me.Caption = "Search for " & GetFormParam(PRF_TABLE)
LoadData
End Sub
Sub LoadData ()
Dim sSQL As String
Dim sCriteria As String
Dim dbBiblio As Database
Dim snLookUp As SnapShot
ReDim sFlds(3) As String
Dim iIndex As Integer
On Error GoTo LoadData_Err
sFlds(1) = "[Company Name]"
sFlds(2) = "Author"
sFlds(3) = "Title"
Set dbBiblio = OpenDatabase(GetAppParam(PRA_DATABASE), True, True)
sSQL = "SELECT DISTINCT * FROM "
sSQL = sSQL & GetFormParam(PRF_TABLE)
sCriteria = GetFormParam(PRF_CRITERIA)
iIndex = Val(GetFormParam(PRF_INDEX))
If sCriteria <> "" Then
sCriteria = " WHERE " & sFlds(iIndex) & " LIKE " & """" & sCriteria & "*" & """"
End If
sSQL = sSQL & sCriteria
Set snLookUp = dbBiblio.CreateSnapshot(sSQL)
If snLookUp.RecordCount <> 0 Then
Do
lstAvailable.AddItem snLookUp.Fields(sFlds(iIndex))
snLookUp.MoveNext
Loop Until snLookUp.EOF
End If
snLookUp.Close
dbBiblio.Close
Exit Sub
LoadData_Err:
MsgBox "Error when Loading Data!" & Chr$(13) & Chr$(13) & Error$ & " (#" & Err & ")", MB_ICONEXCLAMATION
lstAvailable.Clear
Exit Sub
End Sub
Sub lstAvailable_DblClick ()
ReturnValue
End Sub
Sub ReturnValue ()
SetFormParam CStr(lstAvailable.List(lstAvailable.ListIndex)), PRF_RESULT
Unload Me
End Sub